package com.sgb.trip.view.adapter;

import android.content.Context;

import androidx.databinding.DataBindingUtil;

import com.sgb.trip.R;
import com.sgb.trip.databinding.TripItemInsureServiceBinding;
import com.sgb.trip.entity.InsureServiceEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.NumberUtil;

import java.util.List;

/**
 * Time:2021/6/18
 * Author:黄淋
 * Description:选择保险时的adapter
 */
public class InsureServiceAdapter extends BaseRecycleAdapter<InsureServiceEntity> {

    public InsureServiceAdapter(Context context, List<InsureServiceEntity> datas) {
        super(context, R.layout.trip_item_insure_service, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, InsureServiceEntity entity) {
        TripItemInsureServiceBinding binding = DataBindingUtil.bind(holder.itemView);

        if (holder.getItem().isSelected()) {
            binding.ivCheckBox.setBackground(context.getResources().getDrawable(R.mipmap.icon_square_select));
        } else {
            binding.ivCheckBox.setBackground(context.getResources().getDrawable(R.mipmap.icon_square_unselect));
        }
        binding.tvInsureName.setText(entity.getInsuranceName());
        binding.tvInsurePrice.setText("¥" + NumberUtil.trim0(entity.getInsuranceFee()) + "/人");
        binding.tvInsureDetail.setText(entity.getInsuranceDescription());
    }

}
